//
//  commentTableViewCell.m
//  Streaming
//
//  Created by 官琛 on 15-6-27.
//  Copyright (c) 2015年 liuxun. All rights reserved.
//

#import "commentTableViewCell.h"

@implementation commentTableViewCell

 -(void)dealloc
{
    [self.title release];
    [self.summary release];
    [self.userImage release];
    [self.nickname release];
    [self.movieImage release];
    [self.movieTitle release];
    [self.com release];
    [super dealloc];
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        if (WIDTH == 320 && HEIGHT == 568) {
            [self creatTabel5];
        }
        if (WIDTH == 414 && HEIGHT == 736) {
            [self creatTabelPlus];
        }
        if (WIDTH == 375 && HEIGHT == 667){
            [self creatTabel6];
        }
        

    }
    return self;
}

-(void)creatTabel5
{
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 200, 30)];
    self.title.font = [UIFont boldSystemFontOfSize:20];
    [self.contentView addSubview:self.title];
    [_title autorelease];
    
    self.summary = [[UILabel alloc]initWithFrame:CGRectMake(self.title.frame.origin.x, self.title.frame.origin.y+self.title.frame.size.height+5, 200, 50)];
    self.summary.numberOfLines = 0;
    self.summary.font = [UIFont systemFontOfSize:15];
    self.summary.textColor = [UIColor lightGrayColor];
//    [self.summary setBackgroundColor:[UIColor redColor]];
    [self.contentView addSubview:self.summary];
    [_summary autorelease];
    
    self.userImage = [[UIImageView alloc]initWithFrame:CGRectMake(self.summary.frame.origin.x, self.summary.frame.origin.y+self.summary.frame.size.height+5, 30, 30)];
    self.userImage.layer.masksToBounds = YES;
    self.userImage.layer.cornerRadius = 15;
//    [self.userImage setBackgroundColor:[UIColor redColor]];
    [self.contentView addSubview:self.userImage];
    [_userImage autorelease];
    
    self.nickname = [[UILabel alloc]initWithFrame:CGRectMake(self.userImage.frame.origin.x+self.userImage.frame.size.width+6, self.userImage.frame.origin.y, 120, 30)];
    [self.contentView addSubview:self.nickname];
//    [self.nickname setBackgroundColor:[UIColor redColor]];
    [_nickname autorelease];
    
    
    self.movieImage = [[UIImageView alloc]initWithFrame:CGRectMake(self.summary.frame.origin.x+self.summary.frame.size.width+10, self.title.frame.origin.y, 80, 110)];
    self.movieImage.layer.shadowColor = [UIColor blackColor].CGColor;
    self.movieImage.layer.shadowOffset = CGSizeMake(0, 4);
    self.movieImage.layer.shadowOpacity = 0.5;
    self.movieImage.layer.shadowRadius = 10.0;
    [self.contentView addSubview:self.movieImage];
    [_movieImage autorelease];
    
    self.movieTitle = [[UILabel alloc]initWithFrame:CGRectMake(self.movieImage.frame.origin.x-30, self.nickname.frame.origin.y+20, 140, 30)];
    self.movieTitle.textAlignment = NSTextAlignmentCenter;
    self.movieTitle.textColor = [UIColor lightGrayColor];
//    [self.movieTitle setBackgroundColor:[UIColor redColor]];
    [self.contentView addSubview:self.movieTitle];
    [_movieTitle autorelease];
}


-(void)creatTabel6
{
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 200, 30)];
    self.title.font = [UIFont boldSystemFontOfSize:20];
    [self.contentView addSubview:self.title];
    [_title autorelease];
    
    self.summary = [[UILabel alloc]initWithFrame:CGRectMake(self.title.frame.origin.x, self.title.frame.origin.y+self.title.frame.size.height+5, 250, 50)];
    self.summary.numberOfLines = 0;
    self.summary.font = [UIFont systemFontOfSize:15];
    self.summary.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.summary];
    [_summary autorelease];
    
    self.userImage = [[UIImageView alloc]initWithFrame:CGRectMake(self.summary.frame.origin.x, self.summary.frame.origin.y+self.summary.frame.size.height+5, 30, 30)];
    self.userImage.layer.masksToBounds = YES;
    self.userImage.layer.cornerRadius = 15;
    [self.contentView addSubview:self.userImage];
    [_userImage autorelease];
    
    self.nickname = [[UILabel alloc]initWithFrame:CGRectMake(self.userImage.frame.origin.x+self.userImage.frame.size.width+6, self.userImage.frame.origin.y, 120, 30)];
    [self.contentView addSubview:self.nickname];
    [_nickname autorelease];
    
    
    self.movieImage = [[UIImageView alloc]initWithFrame:CGRectMake(self.summary.frame.origin.x+self.summary.frame.size.width+10, self.title.frame.origin.y, 80, 90)];
    self.movieImage.layer.shadowColor = [UIColor blackColor].CGColor;
    self.movieImage.layer.shadowOffset = CGSizeMake(0, 4);
    self.movieImage.layer.shadowOpacity = 0.5;
    self.movieImage.layer.shadowRadius = 10.0;
    [self.contentView addSubview:self.movieImage];
    [_movieImage autorelease];

    self.movieTitle = [[UILabel alloc]initWithFrame:CGRectMake(self.movieImage.frame.origin.x-40, self.nickname.frame.origin.y+10, 140, 30)];
    self.movieTitle.textAlignment = NSTextAlignmentCenter;
    self.movieTitle.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.movieTitle];
    [_movieTitle autorelease];
}

-(void)creatTabelPlus
{
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 200, 30)];
    self.title.font = [UIFont boldSystemFontOfSize:20];
    [self.contentView addSubview:self.title];
    [_title autorelease];
    
    self.summary = [[UILabel alloc]initWithFrame:CGRectMake(self.title.frame.origin.x, self.title.frame.origin.y+self.title.frame.size.height+5, 260, 50)];
    self.summary.numberOfLines = 0;
    self.summary.font = [UIFont systemFontOfSize:15];
    self.summary.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.summary];
    [_summary autorelease];
    
    self.userImage = [[UIImageView alloc]initWithFrame:CGRectMake(self.summary.frame.origin.x+10, self.summary.frame.origin.y+self.summary.frame.size.height+5, 40, 40)];
    self.userImage.layer.masksToBounds = YES;
    self.userImage.layer.cornerRadius = 15;
    [self.contentView addSubview:self.userImage];
    [_userImage autorelease];
    
    self.nickname = [[UILabel alloc]initWithFrame:CGRectMake(self.userImage.frame.origin.x+self.userImage.frame.size.width+15, self.userImage.frame.origin.y, 150, 30)];
    [self.contentView addSubview:self.nickname];
    [_nickname autorelease];
    
    
    self.movieImage = [[UIImageView alloc]initWithFrame:CGRectMake(self.summary.frame.origin.x+self.summary.frame.size.width+20, self.title.frame.origin.y, 100, 110)];
    self.movieImage.layer.shadowColor = [UIColor blackColor].CGColor;
    self.movieImage.layer.shadowOffset = CGSizeMake(0, 4);
    self.movieImage.layer.shadowOpacity = 0.5;
    self.movieImage.layer.shadowRadius = 10.0;
    [self.contentView addSubview:self.movieImage];
    [_movieImage autorelease];
    
    self.movieTitle = [[UILabel alloc]initWithFrame:CGRectMake(self.movieImage.frame.origin.x-25, self.nickname.frame.origin.y+20, 150, 30)];
    self.movieTitle.textAlignment = NSTextAlignmentCenter;
    self.movieTitle.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.movieTitle];
    [_movieTitle autorelease];
}

-(void)setCom:(coment *)com
{
    if (_com != com) {
        [_com release];
        _com = [com retain];
    }
    self.title.text = com.title;
    self.summary.text = com.summary;
    NSString *str = com.nickname;
    self.nickname.text = [NSString stringWithFormat:@"%@ - 评",str];
    NSString *str1 = com.movieTitle;
    self.movieTitle.text = [NSString stringWithFormat:@"《%@》",str1];
    NSURL *url1 = [NSURL URLWithString:com.movieImage];
    [self.movieImage sd_setImageWithURL:url1 placeholderImage:[UIImage imageNamed:@"111111.png"]];
    NSURL *url2 = [NSURL URLWithString:com.userImage];
    [self.userImage sd_setImageWithURL:url2 placeholderImage:[UIImage imageNamed:@"111111.png"]];
    
   
    
    
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
